package edu.pku.sei.transformation.editor.parser.texttemplate.element;

import java.util.Collections;
import java.util.List;

public class StructuredTextElement extends TextElement {
//	private List<ElementEdge> edges = new ArrayList<ElementEdge>();

	public void addSubElements(List<TextElement> subElements) {
		this.addSubElements(subElements, true);
	}
	
	public void addSubElements(List<TextElement> subElements, boolean isRedigst) {
		ElementEdge currentEdge = null;
		for (TextElement templateElement : subElements) {
			currentEdge = new ElementEdge();
			currentEdge.setTarget(templateElement);
			currentEdge.setSource(this);
			this.getEdges().add(currentEdge);
			if (isRedigst)
				this.register.addElement(currentEdge);
		}
	}
	
	@Override
	public String toString() {
		String s = getName() + ":StructuredTextElement";
		return s;
	}
	
	public void sort() {
		Collections.sort(getEdges());
	}
	
	public List<ElementEdge> getEdges() {
		return getOutgoing();
	}
}	
